<?php
class SystemController extends Controller{
	
	public function actionSet(){
		$configModel = Config::model();
		$config = $configModel->find();
		if(isset($_POST['Config'])){
			$config->attributes = $_POST['Config'];
			$data = array(
					'title'=>$_POST['Config']['title'],
					'keywords'=>$_POST['Config']['keywords'],
					'description'=>$_POST['Config']['description'],
					'record'=>$_POST['Config']['record']
			);
			if($config->updateAll($data)){
				Yii::app()->user->setFlash('setSuccess',"修改成功");
			}
		}
		
		$this->render('set',array('config'=>$config));
	}
	
	/**
	 * 更新缓存
	 */
	public function actionClear(){
		if(Yii::app()->request->isAjaxRequest){
			$cachePath = Yii::app()->runtimePath.'/cache';
			$flag = true;
			if(is_dir($cachePath)){
				$flag = Tools::delDir($cachePath);
			}
			if($flag){
				echo '删除成功';
			} else{
				echo '删除失败';
			}
			Yii::app()->end();
		}
	}
}